<%@ Control Language="C#" AutoEventWireup="true" CodeFile="NewsletterSignup.ascx.cs" Inherits="NewsletterSignup" %>
<h3>Sign up for newsletter</h3>
<p>
    If you would like to sign up to receive our newsletter, please provide the 
    following information. This process will also enter you into our system so that 
    if you want to sign up for a library card, you will not have to provide this 
    information again.</p>
<table>
    <tr>
        <td>
            First name:</td>
        <td>
            <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldFirstNameReq" runat="server" 
                ControlToValidate="txtFirstName" ErrorMessage="First name required" 
                ValidationGroup="NewsletterSignup">*</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            Last name:</td>
        <td>
            <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldLastNameReq" runat="server" 
                ControlToValidate="txtLastName" ErrorMessage="Last name required" 
                ValidationGroup="NewsletterSignup">*</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            Address:</td>
        <td>
            <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldAddressReq" runat="server" 
                ControlToValidate="txtAddress" ErrorMessage="Address required" 
                ValidationGroup="NewsletterSignup">*</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            City:</td>
        <td>
            <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldCityReq" runat="server" 
                ControlToValidate="txtCity" ErrorMessage="City required" 
                ValidationGroup="NewsletterSignup">*</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            State:</td>
        <td>
            <asp:DropDownList ID="ddlState" runat="server">
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
        <td>
            Zip:</td>
        <td>
            <asp:TextBox ID="txtZip" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldZipReq" runat="server" 
                ControlToValidate="txtZip" ErrorMessage="Zip required" 
                ValidationGroup="NewsletterSignup" Text="*"></asp:RequiredFieldValidator>
        &nbsp;<asp:RegularExpressionValidator ID="vldZipFormat" runat="server" 
                ErrorMessage="Please enter a valid zip code" ControlToValidate="txtZip" 
                ValidationExpression="^\d{5}(\-\d{4})?$" 
                ValidationGroup="NewsletterSignup">*</asp:RegularExpressionValidator></td>
    </tr>
    <tr>
        <td>
            Phone number:</td>
        <td>
            <asp:TextBox ID="txtPhoneNumber" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldPhoneNumberReq" runat="server" 
                ControlToValidate="txtPhoneNumber" ErrorMessage="Phone number required" 
                ValidationGroup="NewsletterSignup" Text="*"></asp:RequiredFieldValidator>
        &nbsp;<asp:RegularExpressionValidator ID="vldPhoneNumberFormat" runat="server" 
                ErrorMessage="Enter the phone number like 5554443333" 
                ControlToValidate="txtPhoneNumber" 
                ValidationExpression="\d{10}" ValidationGroup="NewsletterSignup">*</asp:RegularExpressionValidator></td>
    </tr>
    <tr>
        <td>
            Email:</td>
        <td>
            <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldEmailReq" runat="server" 
                ControlToValidate="txtEmail" ErrorMessage="Email required" 
                ValidationGroup="NewsletterSignup" Display="Dynamic">*</asp:RequiredFieldValidator>
            &nbsp;<asp:RegularExpressionValidator ID="vldEmailFormat" runat="server" 
                ErrorMessage="The email should be entered like name@gmail.com or email@comcast.net" 
                ControlToValidate="txtEmail" 
                ValidationExpression="(?&lt;user&gt;(?:(?:[^ \t\(\)\&lt;\&gt;@,;\:\\\&quot;\.\[\]\r\n]+)|(?:\&quot;(?:(?:[^\&quot;\\\r\n])|(?:\\.))*\&quot;))(?:\.(?:(?:[^ \t\(\)\&lt;\&gt;@,;\:\\\&quot;\.\[\]\r\n]+)|(?:\&quot;(?:(?:[^\&quot;\\\r\n])|(?:\\.))*\&quot;)))*)@(?&lt;domain&gt;(?:(?:[^ \t\(\)\&lt;\&gt;@,;\:\\\&quot;\.\[\]\r\n]+)|(?:\[(?:(?:[^\[\]\\\r\n])|(?:\\.))*\]))(?:\.(?:(?:[^ \t\(\)\&lt;\&gt;@,;\:\\\&quot;\.\[\]\r\n]+)|(?:\[(?:(?:[^\[\]\\\r\n])|(?:\\.))*\])))*)" 
                ValidationGroup="NewsletterSignup" Display="Dynamic">*</asp:RegularExpressionValidator></td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td>
            &nbsp;
            <asp:ValidationSummary ID="vsNewsletterSignup" runat="server" 
                ValidationGroup="NewsletterSignup" />
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td>
            <asp:Button ID="btnSignUp" runat="server" Text="Sign up" 
                ValidationGroup="NewsletterSignup" onclick="btnSignUp_Click" />
        </td>
    </tr>
</table>

<asp:Label ID="lblSuccess" runat="server" 
    Text="Thank you, you have been successfully added to the system. You should get the next email when it is sent out." 
    Visible="False"></asp:Label>


